package coc.example.script.crawler.公共.登录;

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;

import coc.core.CrawlerConfig;
import coc.core.SpiderResult;
import coc.example.config.Dirs;
import coc.example.script.crawler.BaseCrawler;
import coo.base.exception.UncheckedException;

public class LoginCrawler extends BaseCrawler {
	public LoginCrawler(CrawlerConfig config) {
		super(config);
	}

	@Override
	protected Integer saveSpiderResult(SpiderResult spiderResult) {
		super.saveSpiderResult(spiderResult);
		try {
			FileOutputStream fos = new FileOutputStream(Dirs.COOKIES.getPath()
					+ "/" + spiderResult.getTaskName() + ".cookie");
			ObjectOutputStream oos = new ObjectOutputStream(fos);
			oos.writeObject(spiderResult.getData());
			oos.flush();
			oos.close();
		} catch (Exception e) {
			throw new UncheckedException(e);
		}
		return spiderResult.getDataSize();
	}
}
